package ma.ensias.healthme;

import java.util.ArrayList;

import ma.ensias.healthme.entities.Maladie;
import ma.ensias.healthme.entities.Personne;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class MaladieLazyAdapter extends BaseAdapter {
    
    private Activity activity;
    private ArrayList<Maladie> data;
    private ArrayList<Float> data1;
    private static LayoutInflater inflater=null;
    
    public MaladieLazyAdapter(Activity a, ArrayList<Maladie> d,ArrayList<Float> pers) {
        activity = a;
        data=d;
        data1=pers;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return data.get(position);
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent) {
		View vi=convertView;
		if(convertView==null)
		 vi = inflater.inflate(R.layout.maladie_row_c, null);
		
		TextView maladie = (TextView)vi.findViewById(R.id.maladieL); // title
		TextView num = (TextView)vi.findViewById(R.id.num); // title
		TextView persen = (TextView)vi.findViewById(R.id.persen); // title
		Maladie m=data.get(position);
		maladie.setText(m.getNom());
		num.setText(""+(position+1));
		persen.setText(""+data1.get(position).floatValue()+" %");
		return vi;
    }
}